<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!--准备好一个容器-->
    <div id="test"></div>
    <!--引入核心库-->
    <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <!--引入react-dom支持react操纵dom-->
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <!--引入babel用于将jsx转为js-->
    <script src="../js/babel.min.js"></script>
    <!--引入prop-types,用于对标签属性进行限制-->
    <script src="../js/prop-types.js">//引入之后全局会产生一个PropType对象</script>

    <script type="text/babel">
        //创建组件
        class Time extends React.Component {
            //初始化状态
            state = { date: new Date() }

            componentDidMount() {
                setInterval(() => {
                    this.setState({
                        date: new Date()
                    })
                }, 1000);
            }

            //定义组件挂载的形态
            render() {
                return (
                    <div>
                        <h1>hello</h1>
                        <input type="text" />
                        <span>现在是:{this.state.date.toTimeString()}</span>
                    </div>
                )
            }


        }
        //渲染组件到页面
        ReactDOM.render(<Time />, document.getElementById('test'))
    </script>
</body>

</html>